﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using com.vs.General;
using com.vs.General.RF;
using com.vs.DataAccess;
using com.vs.DataAccess.DO;

namespace com.vs.RF.Web.receiving
{
    public partial class ReceiptIDEntryHandling :RFHandlingPage
    {
        private string stReceiptID = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            stSourcePage = "ReceiptIDEntry.aspx";
            stTargetPage = "receiving/ItemEntry.aspx";
            go();
        }

        protected override void parseRequest()
        {
            stReceiptID = Request["tbReceiptID"];
            if (StringManager.IsEmpty(stReceiptID))
                stError = MessageManager.MSG_RCP_030;//错误：收货单号必须输入
        }

        protected override void procData()
        {
            List<ReceiptHeaderDO> ltRcp = null;
            ReceiptHeaderDO rhDO = null;

            try
            {
                ltRcp = ReceiptHeaderDO.GetListByColumn(rfSess, "RECEIPT_ID", this.stReceiptID);
                if (ltRcp == null)
                {
                    stError = MessageManager.MSG_RCP_013; //收货单未找到
                    return;
                }

                if (ltRcp.Count > 1)
                {
                    stTargetPage = "ChooseReceiptID.aspx";
                    return;
                }
                rhDO = ltRcp[0];

                if (rhDO.TRAILING_STS == 900)
                {
                    stError = MessageManager.MSG_RCP_031; //收货单已完成
                    return;
                }

                Session[RFSupport.RECEIPT_ID] = stReceiptID;
                Session[RFSupport.INTERNAL_RECEIPT_NUM] = rhDO.INTERNAL_RECEIPT_NUM;
            }
            catch (Exception e)
            {
                ExceptionManager.LogException(rfSess, e);
                stError = e.Message;
            }
        }
    }
}
